import { getSystemUser, addSystemUser, enabledControl, getSystemUserById } from '@/services/settings/user/systemUserService';

export default {
    namespace: 'systemUserModel',

    state: {},

    effects: {
        * fetch({ payload, callback }, { call, put }) {
            const response = yield call(getSystemUser, payload);

            if (callback) callback(response);
        },
        * fetchById({ payload, callback }, { call, put }) {
          const response = yield call(getSystemUserById, payload);

          if (callback) callback(response);
        },
        * add({ payload, callback }, { call, put }) {
            const response = yield call(addSystemUser, payload);

            if (callback) callback(response);
        },
        * update({ payload, callback }, { call, put }) {
            const response = yield call(updateMenu, payload);

            if (callback) callback(response);
        },
        * enabledControl({ payload, callback }, { call, put }) {
            const response = yield call(enabledControl, payload);

            if (callback) callback(response);
        }
    },

    reducers: {
        RCallback(state, action) {
            return {
                ...state,
                data: action.response.datas,
                requestFinish: true,
            };
        },
    },
};
